# 初始化
import datetime
import os

import django

from dvadmin.utils.core_initialize import CoreInitialize

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'application.settings')
django.setup()

from dvadmin.system.models import Dept, Button, Menu, MenuButton, Role, Users


class Initialize(CoreInitialize):
    creator_id = 1

    def init_dept(self):
        """
        初始化部门信息
        """
        self.dept_data = [
            {
                "id": 1,
                "description": "",
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "DVAdmin团队",
                "sort": 1,
                "owner": "",
                "phone": "",
                "email": "",
                "status": 1,
                "creator_id": 1,
                "dept_id":1,
                "parent_id": None
            }
        ]
        self.save(Dept, self.dept_data, "部门信息")

    def init_button(self):
        """
        初始化按钮表
        """
        self.button_data = [
            {
                "id": 1,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "新增",
                "value": "Create",
                "creator_id": 1
            },
            {
                "id": 2,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "编辑",
                "value": "Update",
                "creator_id": 1
            },
            {
                "id": 3,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "删除",
                "value": "Delete",
                "creator_id": 1
            },
            {
                "id": 4,
                "description": "",
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "详情",
                "value": "Retrieve",
                "creator_id": 1
            },
            {
                "id": 5,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "查询",
                "value": "Search",
                "creator_id": 1
            },
            {
                "id": 6,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "保存",
                "value": "Save",
                "creator_id": 1
            },
            {
                "id": 7,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "导入",
                "value": "Import",
                "creator_id": 1
            },
            {
                "id": 8,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "导出",
                "value": "Export",
                "creator_id": 1
            },
            {
                "id": 9,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "重置密码",
                "value": "ResetPwd",
                "creator_id": 1
            }
        ]
        self.save(Button, self.button_data, "权限表标识")

    def init_menu(self):
        """
        初始化菜单表
        """
        self.menu_data = [
            {
                "id": 1,
                "description": "",
                "modifier": "1",
                "dept_belong_id": "",
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "icon": "el-icon-notebook-1",
                "name": "菜单管理",
                "sort": 1,
                "path": "/system/menu",
                "component_name": "menu",
                "status": 1,
                "nocache": 0,
                "hidden": 1,
                "creator_id": 1,
                "parent_id": 2,
                "is_catalog": 0
            },
            {
                "id": 2,
                "description": "",
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "icon": "el-icon-setting",
                "name": "系统管理",
                "sort": 1,
                "path": "/system",
                "component": "#",
                "status": 1,
                "nocache": 0,
                "hidden": 1,
                "creator_id": 1,
                "parent_id": None,
                "is_catalog": 1
            },
            {
                "id": 3,
                "description": "",
                "modifier": "1",
                "dept_belong_id": "",
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "icon": "el-icon-user-solid",
                "name": "用户管理",
                "sort": 6,
                "path": "/system/user",
                "component": "user",
                "status": 1,
                "nocache": 0,
                "hidden": 1,
                "creator_id": 1,
                "parent_id": 2,
                "is_catalog": 0
            },
            {
                "id": 4,
                "description": "",
                "modifier": "1",
                "dept_belong_id": "",
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "icon": "el-icon-s-custom",
                "name": "角色管理",
                "sort": 4,
                "path": "/system/role",
                "component": "role",
                "status": 1,
                "nocache": 0,
                "hidden": 1,
                "creator_id": 1,
                "parent_id": 2,
                "is_catalog": 0
            },
            {
                "id": 5,
                "description": "",
                "modifier": "1",
                "dept_belong_id": "",
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "icon": "el-icon-menu",
                "name": "部门管理",
                "sort": 4,
                "path": "/system/dept",
                "component": "dept",
                "status": 1,
                "nocache": 0,
                "hidden": 1,
                "creator_id": 1,
                "parent_id": 2,
                "is_catalog": 0
            },
            {
                "id": 6,
                "description": "",
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "icon": "el-icon-setting",
                "name": "权限管理",
                "sort": 3,
                "path": "/system/rolePermission",
                "component": "rolePermission",
                "status": 1,
                "nocache": 0,
                "hidden": 1,
                "creator_id": 1,
                "parent_id": 2,
                "is_catalog": 0
            },
            {
                "id": 7,
                "description": "",
                "modifier": "1",
                "dept_belong_id": "",
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "icon": "el-icon-mouse",
                "name": "菜单按钮",
                "sort": 2,
                "path": "/system/menuButton",
                "component": "menuButton",
                "status": 1,
                "nocache": 0,
                "hidden": 0,
                "creator_id": 1,
                "parent_id": 2,
                "is_catalog": 0
            },
            {
                "id": 8,
                "description": "",
                "modifier": "1",
                "dept_belong_id": "",
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "icon": "el-icon-set-up",
                "name": "按钮管理",
                "sort": 2,
                "path": "/system/button",
                "component": "button",
                "status": 1,
                "nocache": 0,
                "hidden": 0,
                "creator_id": 1,
                "parent_id": 2,
                "is_catalog": 0
            },
            {
                "id": 9,
                "description": "",
                "modifier": "1",
                "dept_belong_id": "",
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "icon": "el-icon-mouse",
                "name": "接口白名单",
                "sort": 7,
                "path": "/system/apiWhiteList",
                "component": "whiteList",
                "status": 1,
                "nocache": 0,
                "hidden": 1,
                "creator_id": 1,
                "parent_id": 2,
                "is_catalog": 0
            },
            {
                "id": 10,
                "description": "",
                "modifier": "1",
                "dept_belong_id": "",
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "icon": "el-icon-document",
                "name": "字典管理",
                "sort": 1,
                "path": "/commonset/dictionary",
                "component": "dictionary",
                "status": 1,
                "nocache": 0,
                "hidden": 1,
                "creator_id": 1,
                "parent_id": 17,
                "is_catalog": 0
            },
            {
                "id": 11,
                "description": "",
                "modifier": "1",
                "dept_belong_id": "",
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "icon": "el-icon-place",
                "name": "地区管理",
                "sort": 2,
                "path": "/commonset/areas",
                "component": "areas",
                "status": 1,
                "nocache": 0,
                "hidden": 1,
                "creator_id": 1,
                "parent_id": 17,
                "is_catalog": 0
            },
            {
                "id": 13,
                "description": "",
                "modifier": "1",
                "dept_belong_id": "",
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "icon": "el-icon-files",
                "name": "附件管理",
                "sort": 3,
                "path": "/commonset/file",
                "component": "file",
                "status": 1,
                "nocache": 0,
                "hidden": 1,
                "creator_id": 1,
                "parent_id": 17,
                "is_catalog": 0
            },
            {
                "id": 15,
                "description": "",
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "icon": "el-icon-tickets",
                "name": "日志管理",
                "sort": 3,
                "path": "/log",
                "component": "#",
                "status": 1,
                "nocache": 0,
                "hidden": 1,
                "creator_id": 1,
                "parent_id": None,
                "is_catalog": 1
            },
            {
                "id": 16,
                "description": "",
                "modifier": "1",
                "dept_belong_id": "",
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "icon": "el-icon-tickets",
                "name": "操作日志",
                "sort": 2,
                "path": "/log/operationLog",
                "component": "operationLog",
                "status": 1,
                "nocache": 0,
                "hidden": 1,
                "creator_id": 1,
                "parent_id": 15,
                "is_catalog": 0
            },
            {
                "id": 17,
                "description": "",
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "icon": "el-icon-tickets",
                "name": "常规配置",
                "sort": 2,
                "path": "/commonset",
                "component": "#",
                "status": 1,
                "nocache": 0,
                "hidden": 1,
                "creator_id": 1,
                "parent_id": None,
                "is_catalog": 1
            }
        ]
        self.save(Menu, self.menu_data, "菜单表")

    def init_menu_button(self):
        """
        初始化菜单按钮表
        """
        self.menu_button_data = [
            {
                "id": 1,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "查询",
                "value": "Search",
                "api": "/api/system/menu/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 1
            },
            {
                "id": 2,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "编辑",
                "value": "Update",
                "api": "/api/system/menu/{id}/",
                "method": 2,
                "creator_id": 1,
                "menu_id": 1
            },
            {
                "id": 3,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "新增",
                "value": "Create",
                "api": "/api/system/menu/",
                "method": 1,
                "creator_id": 1,
                "menu_id": 1
            },
            {
                "id": 4,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "详情",
                "value": "Retrieve",
                "api": "/api/system/menu/{id}/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 1
            },
            {
                "id": 5,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "删除",
                "value": "Delete",
                "api": "/api/system/menu/{id}/",
                "method": 3,
                "creator_id": 1,
                "menu_id": 1
            },
            {
                "id": 6,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "编辑",
                "value": "Update",
                "api": "/api/system/user/{id}/",
                "method": 2,
                "creator_id": 1,
                "menu_id": 3
            },
            {
                "id": 7,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "查询",
                "value": "Search",
                "api": "/api/system/user/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 3
            },
            {
                "id": 8,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "详情",
                "value": "Retrieve",
                "api": "/api/system/user/{id}/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 3
            },
            {
                "id": 9,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "新增",
                "value": "Create",
                "api": "/api/system/user/",
                "method": 1,
                "creator_id": 1,
                "menu_id": 3
            },
            {
                "id": 10,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "删除",
                "value": "Delete",
                "api": "/api/system/user/{id}/",
                "method": 3,
                "creator_id": 1,
                "menu_id": 3
            },
            {
                "id": 11,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "编辑",
                "value": "Update",
                "api": "/api/system/role/{id}/",
                "method": 2,
                "creator_id": 1,
                "menu_id": 4
            },
            {
                "id": 12,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "查询",
                "value": "Search",
                "api": "/api/system/role/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 4
            },
            {
                "id": 13,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "详情",
                "value": "Retrieve",
                "api": "/api/system/role/{id}/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 4
            },
            {
                "id": 14,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "新增",
                "value": "Create",
                "api": "/api/system/role/",
                "method": 1,
                "creator_id": 1,
                "menu_id": 4
            },
            {
                "id": 15,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "删除",
                "value": "Delete",
                "api": "/api/system/role/{id}/",
                "method": 3,
                "creator_id": 1,
                "menu_id": 4
            },
            {
                "id": 16,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "编辑",
                "value": "Update",
                "api": "/api/system/dept/{id}/",
                "method": 2,
                "creator_id": 1,
                "menu_id": 5
            },
            {
                "id": 17,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "查询",
                "value": "Search",
                "api": "/api/system/dept/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 5
            },
            {
                "id": 18,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "详情",
                "value": "Retrieve",
                "api": "/api/system/dept/{id}/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 5
            },
            {
                "id": 19,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "新增",
                "value": "Create",
                "api": "/api/system/dept/",
                "method": 1,
                "creator_id": 1,
                "menu_id": 5
            },
            {
                "id": 20,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "删除",
                "value": "Delete",
                "api": "/api/system/dept/{id}/",
                "method": 3,
                "creator_id": 1,
                "menu_id": 5
            },
            {
                "id": 21,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "编辑",
                "value": "Update",
                "api": "/api/system/menu_button/{id}/",
                "method": 2,
                "creator_id": 1,
                "menu_id": 7
            },
            {
                "id": 22,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "查询",
                "value": "Search",
                "api": "/api/system/menu_button/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 7
            },
            {
                "id": 23,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "新增",
                "value": "Create",
                "api": "/api/system/menu_button/",
                "method": 1,
                "creator_id": 1,
                "menu_id": 7
            },
            {
                "id": 24,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "删除",
                "value": "Delete",
                "api": "/api/system/menu_button/{id}/",
                "method": 3,
                "creator_id": 1,
                "menu_id": 7
            },
            {
                "id": 25,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "新增",
                "value": "Create",
                "api": "/api/system/button/",
                "method": 1,
                "creator_id": 1,
                "menu_id": 8
            },
            {
                "id": 26,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "编辑",
                "value": "Update",
                "api": "/api/system/button/{id}/",
                "method": 2,
                "creator_id": 1,
                "menu_id": 8
            },
            {
                "id": 27,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "查询",
                "value": "Search",
                "api": "/api/system/button/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 8
            },
            {
                "id": 28,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "删除",
                "value": "Delete",
                "api": "/api/system/button/{id}/",
                "method": 3,
                "creator_id": 1,
                "menu_id": 8
            },
            {
                "id": 29,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "保存",
                "value": "Save",
                "api": "/api/system/role/{id}/",
                "method": 2,
                "creator_id": 1,
                "menu_id": 6
            },
            {
                "id": 30,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "编辑",
                "value": "Update",
                "api": "/api/system/api_white_list/{id}/",
                "method": 2,
                "creator_id": 1,
                "menu_id": 9
            },
            {
                "id": 31,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "查询",
                "value": "Search",
                "api": "/api/system/api_white_list/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 9
            },
            {
                "id": 32,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "详情",
                "value": "Retrieve",
                "api": "/api/system/api_white_list/{id}/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 9
            },
            {
                "id": 33,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "新增",
                "value": "Create",
                "api": "/api/system/api_white_list/",
                "method": 1,
                "creator_id": 1,
                "menu_id": 9
            },
            {
                "id": 34,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "删除",
                "value": "Delete",
                "api": "/api/system/api_white_list/{id}/",
                "method": 3,
                "creator_id": 1,
                "menu_id": 9
            },
            {
                "id": 35,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "编辑",
                "value": "Update",
                "api": "/api/system/dictionary/{id}/",
                "method": 2,
                "creator_id": 1,
                "menu_id": 10
            },
            {
                "id": 36,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "查询",
                "value": "Search",
                "api": "/api/system/dictionary/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 10
            },
            {
                "id": 37,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "详情",
                "value": "Retrieve",
                "api": "/api/system/dictionary/{id}/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 10
            },
            {
                "id": 38,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "新增",
                "value": "Create",
                "api": "/api/system/dictionary/",
                "method": 1,
                "creator_id": 1,
                "menu_id": 10
            },
            {
                "id": 39,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "删除",
                "value": "Delete",
                "api": "/api/system/dictionary/{id}/",
                "method": 3,
                "creator_id": 1,
                "menu_id": 10
            },
            {
                "id": 40,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "编辑",
                "value": "Update",
                "api": "/api/system/area/{id}/",
                "method": 2,
                "creator_id": 1,
                "menu_id": 11
            },
            {
                "id": 41,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "查询",
                "value": "Search",
                "api": "/api/system/area/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 11
            },
            {
                "id": 42,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "详情",
                "value": "Retrieve",
                "api": "/api/system/area/{id}/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 11
            },
            {
                "id": 43,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "新增",
                "value": "Create",
                "api": "/api/system/area/",
                "method": 1,
                "creator_id": 1,
                "menu_id": 11
            },
            {
                "id": 44,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "删除",
                "value": "Delete",
                "api": "/api/system/area/{id}/",
                "method": 3,
                "creator_id": 1,
                "menu_id": 11
            },
            {
                "id": 45,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "详情",
                "value": "Retrieve",
                "api": "/api/system/operation_log/{id}/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 16
            },
            {
                "id": 46,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "查询",
                "value": "Search",
                "api": "/api/system/operation_log/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 16
            },
            {
                "id": 47,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "导出",
                "value": "Export",
                "api": "/api/system/user/export/",
                "method": 1,
                "creator_id": 1,
                "menu_id": 3
            },
            {
                "id": 48,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "导入",
                "value": "Import",
                "api": "/api/system/user/import/",
                "method": 1,
                "creator_id": 1,
                "menu_id": 3
            },
            {
                "id": 49,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "详情",
                "value": "Retrieve",
                "api": "/api/system/file/{id}/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 13
            },
            {
                "id": 50,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "查询",
                "value": "Search",
                "api": "/api/system/file/",
                "method": 0,
                "creator_id": 1,
                "menu_id": 13
            },
            {
                "id": 51,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "删除",
                "value": "Delete",
                "api": "/api/system/file/{id}/",
                "method": 3,
                "creator_id": 1,
                "menu_id": 13
            },
            {
                "id": 52,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "编辑",
                "value": "Update",
                "api": "/api/system/file/{id}/",
                "method": 1,
                "creator_id": 1,
                "menu_id": 13
            },
            {
                "id": 53,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "重置密码",
                "value": "ResetPwd",
                "api": "/api/system/user/reset_password/{id}/",
                "method": 2,
                "creator_id": 1,
                "menu_id": 3
            }
        ]
        self.save(MenuButton, self.menu_button_data, "菜单按钮表")

    def init_role(self):
        """
        初始化角色表
        """
        data = [
            {
                "id": 1,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "name": "管理员",
                "key": "admin",
                "sort": 1,
                "status": 1,
                "admin": 1,
                "data_range": 3,
                "menu": [ele.get("id") for ele in self.menu_data],
                "permission": [ele.get("id") for ele in self.menu_button_data],
                "remark": None,
                "creator_id": 1
            }
        ]
        self.save(Role, data, "角色表")

    def init_users(self):
        """
        初始化用户表
        """
        data = [
            {
                "password": "pbkdf2_sha256$260000$g17x5wlSiW1FZAh1Eudchw$ZeSAqj3Xak0io8v/pmPW0BX9EX5R2zFXDwbbD68oBFk=",
                "last_login": None,
                "is_superuser": 1,
                "first_name": "",
                "last_name": "",
                "is_staff": 1,
                "is_active": 1,
                "id": 1,
                "description": None,
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "username": "superadmin",
                "email": "dvadmin@django-vue-admin.com",
                "mobile": "13333333333",
                "avatar": None,
                "name": "超级管理员",
                "gender": 1,
                "creator_id": None,
                "dept_id": 1
            },
            {
                "password": "pbkdf2_sha256$260000$g17x5wlSiW1FZAh1Eudchw$ZeSAqj3Xak0io8v/pmPW0BX9EX5R2zFXDwbbD68oBFk=",
                "last_login": None,
                "is_superuser": 0,
                "first_name": "",
                "last_name": "",
                "is_staff": 1,
                "is_active": 1,
                "id": 2,
                "description": "",
                "modifier": "1",
                "dept_belong_id": 1,
                "update_datetime": datetime.datetime.now(),
                "create_datetime": datetime.datetime.now(),
                "username": "admin",
                "email": "dvadmin@django-vue-admin1.com",
                "mobile": "13333333331",
                "avatar": "",
                "name": "管理员",
                "gender": 1,
                "creator_id": None,
                "dept_id": 1,
                "role": [1],
            }
        ]
        self.save(Users, data, "用户表", no_reset=True)

    def run(self):
        self.init_dept()
        self.init_button()
        self.init_menu()
        self.init_menu_button()
        self.init_role()
        self.init_users()


# 项目init 初始化，默认会执行 main 方法进行初始化
def main(reset=False):
    Initialize(reset).run()
    pass


if __name__ == '__main__':
    main()
